<%@page import="com.dfhc.dfhc.dfhcprojectfunction.IProjectFunctionConstants" %>
<%@page import="com.dfhc.dfhc.dfhcprojectmodule.IProjectModuleConstants" %>
<%@page import="com.dfhc.ISystemConstant"%>


<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<%@ taglib uri="/dfhc" prefix="dfhc" %>
<!-- 全局js 和css包 -->
<%@ include file="/jsp/include/web/new/global.jsp" %>
<title>定制项目模块管理</title>
</head>
<body>

<dfhc:template templateUrl="/pubController/getLayoutTemp/?jspUrl=/temp/huiMasterSubTabTemp" >	
 	<dfhc:region name="mainTableFormRegion"> 	




	   <input type="hidden" id="id" name="id" value="${bean.id}">							
	   <input type="hidden" id="url" name="url" value="">
	   <input type="hidden" id="refreshUrl" name="refreshUrl" value="">
	    <dfhc:div templateId="h_ui_div_row_cl">
	    <dfhc:title templateId="h_ui_label_title"><%=IProjectModuleConstants.TABLE_COLUMN_DISPLAY.get("projectId")%>：</dfhc:title>	    
	    <dfhc:div templateId="h_ui_div_fromcontrol">	        
			<dfhc:input templateId="h_ui_input" value="${bean.projectId}" placeholder="" id="projectId" name="projectId"/>			
	    </dfhc:div>	    		 
	  </dfhc:div>
	    <dfhc:div templateId="h_ui_div_row_cl">
	    <dfhc:title templateId="h_ui_label_title"><%=IProjectModuleConstants.TABLE_COLUMN_DISPLAY.get("name")%>：</dfhc:title>	    
	    <dfhc:div templateId="h_ui_div_fromcontrol">	        
			<dfhc:input templateId="h_ui_input" value="${bean.name}" placeholder="" id="name" name="name"/>			
	    </dfhc:div>	    		 
	  </dfhc:div>
	    <dfhc:div templateId="h_ui_div_row_cl">
	    <dfhc:title templateId="h_ui_label_title"><%=IProjectModuleConstants.TABLE_COLUMN_DISPLAY.get("remark")%>：</dfhc:title>	    
		<dfhc:div templateId="h_ui_div_row_cl">
			<dfhc:div templateId="h_ui_div_fromcontrol">			    
<dfhc:textarea name="remark" cols="" rows=""   placeholder="说点什么..."  maxlength="255"   templateId="h_ui_textarea" >${bean.remark}</dfhc:textarea>		
			</dfhc:div>
		</dfhc:div>
	  </dfhc:div>
    </dfhc:region>
    <dfhc:region name="mainTableButtonRegion">
    	<dfhc:div templateId="h_ui_div_row_cl">
		<dfhc:div templateId="h_ui_div_pop_up_button">
        <%--  <dfhc:button templateId="h_ui_save_button" onclick="saveMain()" /> --%>
         <dfhc:button templateId="h_ui_submit_button" onclick="commitMain()" />	
	    </dfhc:div>
	    </dfhc:div>    
    </dfhc:region>
      

    
<dfhc:region name="subTableRegions">
     <c:if test="${not empty bean}">
     <dfhc:template templateUrl="/pubController/getLayoutTemp/?jspUrl=/temp/huiSubTabTemp" >
       <dfhc:region name="subTableButtonRegion">     
        <dfhc:div templateId="h_ui_div_table_button">
        <dfhc:span templateId="h_ui_button_span">
         <dfhc:button templateId="h_ui_add_button" onclick="_showPage('添加项目功能','${pageContext.request.contextPath }/dfhcprojectfunction/addMainSubPage?moduleId=${bean.id}','550','510')" />
         <dfhc:button templateId="h_ui_update_button" onclick="singleEdit('修改项目功能','${pageContext.request.contextPath }/dfhcprojectfunction/showMainSubPage?moduleId=${bean.id}','550','510')" />
	     <%-- <dfhc:button templateId="h_ui_delete_button" onclick="singleDelete('${pageContext.request.contextPath }/dfhcprojectfunction/delete')" /> --%>
		</dfhc:span>				
	    </dfhc:div>						          
     </dfhc:region> 
    <dfhc:region name="subTableRegion">
	<dfhc:table templateId="table_h_ui" >    	
		<dfhc:thead>
			<dfhc:tr> 
				<dfhc:th width="25">
				   <dfhc:checkbox name="allId" />
				</dfhc:th>	
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IProjectFunctionConstants.TABLE_COLUMN_DISPLAY.get("moduleName")%></dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IProjectFunctionConstants.TABLE_COLUMN_DISPLAY.get("projectFunction")%></dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IProjectFunctionConstants.TABLE_COLUMN_DISPLAY.get("expectedWorkingTime")%></dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IProjectFunctionConstants.TABLE_COLUMN_DISPLAY.get("startTime")%></dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IProjectFunctionConstants.TABLE_COLUMN_DISPLAY.get("expectedEndTime")%></dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IProjectFunctionConstants.TABLE_COLUMN_DISPLAY.get("workingDay")%></dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IProjectFunctionConstants.TABLE_COLUMN_DISPLAY.get("actualEndTime")%></dfhc:title>
				</dfhc:th>
			</dfhc:tr>
    	   </dfhc:thead>			
	</dfhc:table>           
    	

	</dfhc:region>		     
	</dfhc:template>
	</c:if>		
    </dfhc:region>
    
  
        
</dfhc:template>    

<script type="text/javascript">
var _table;
$(function(){
	//获取新id
	<c:if test="${empty bean}"> 
	$('#id').val(getNewId('<%=IProjectModuleConstants.TABLE_NAME%>'));
	</c:if>
	$("#form-add").validate({
		rules:{
			name:{			
				maxlength:255
			},
			remark:{			
				maxlength:255
			}
		},
 		messages: {
			name:{
		        maxlength: "模块名称最大长度为255个字母"
	           },
			remark:{
		        maxlength: "备注最大长度为255个字母"
	           }
	    },		
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			if(isStrEmpty($("#refreshUrl").val())){
				alert($("#url").val());
			 //提交成功关闭
			 submitAjax($("#url").val(),$("#form-add").serialize());
			}else{
				alert($("#url").val());
			 //提交成功关闭
			 submitAjax($("#url").val(),$("#form-add").serialize(),$("#refreshUrl").val());			 
			}
		}
	});

	<c:if test="${not empty bean}">

	_table = $('.table-sort').dataTable({	
	     dom: 'Zlfrtip',	   		
		 ajax : function(data, callback, settings) {
		       var param=''; 
                $.ajax({  
                        type: "GET",  
                        url: getRootPath()+"/dfhcprojectfunction/ajaxList?jsguid=<%=session.getId()%>&moduleId="+$('#id').val(),  
                        cache : false,  //禁用缓存  
                        data:param,   
                        dataType: "json",  
                        success: function(result) {  
                                //异常判断与处理  
                                if (result.status=='0') {  
                                    alert(result.message);  
                                    return;  
                                }  
                                //封装返回数据  
                                var returnData = {};  
                                returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回  
                                returnData.recordsTotal = result.recordsTotal;//总记录数  
                                returnData.recordsFiltered = result.recordsTotal;//后台不实现过滤功能，每次查询均视作全部结果  
                                returnData.data = result.data;  
                                //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染  
                                //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕  
                                callback(returnData);  
                                //更新总记录数
                                $("#totalRecodSpan").html('共有数据：<strong>'+result.recordsTotal+'</strong> 条</span>');
                        },  
                        error: function(XMLHttpRequest, textStatus, errorThrown) {  
                            alert("查询失败");  
                        }  
                    });  
            },  
		"columns": [
		  {
		    "data":"id",
			"render":function(data,type,row,meta){
			   var content='<input type="checkbox" name="allId" value="'+row.id+'"/>';
			   return content; 
			}
		  },
		  {"data":"moduleName"},
		  {"data":"projectFunction"},
		  {	   
		    "data":"expectedWorkingTime",
		    "defaultContent":"",
		    render:function(data,type,row,meta){
		    var content=formatDate(row.expectedWorkingTime,'yyyy-MM-dd HH:mm:ss');			 
		    return content; 
		  }
		  },
		  {	   
		    "data":"startTime",
		    "defaultContent":"",
		    render:function(data,type,row,meta){
		    var content=formatDate(row.startTime,'yyyy-MM-dd HH:mm:ss');			 
		    return content; 
		  }
		  },
		  {	   
		    "data":"expectedEndTime",
		    "defaultContent":"",
		    render:function(data,type,row,meta){
		    var content=formatDate(row.expectedEndTime,'yyyy-MM-dd HH:mm:ss');			 
		    return content; 
		  }
		  },
		  {"data":"workingDay"},
		  {	   
		    "data":"actualEndTime",
		    "defaultContent":"",
		    render:function(data,type,row,meta){
		    var content=formatDate(row.actualEndTime,'yyyy-MM-dd HH:mm:ss');			 
		    return content; 
		  }
		  }
		],
		"columnDefs": [ {"searchable": false,
            "orderable": false,
            "targets": 0 }]  				
	});  
	</c:if>	
});

/**
 * 保存主表
 */
function saveMain(){
    var refreshUrl;
	<c:if test="${empty bean}"> 
	var url = getRootPath()+"/dfhcprojectmodule/insert?jsguid="+$('#id').val();
	if(location.href.indexOf("?")==-1){
		refreshUrl= location.href+"?id="+$('#id').val();
	}else{
		refreshUrl= location.href+"&id="+$('#id').val();
	}	
	</c:if>
	<c:if test="${not empty bean}"> 
	var url = getRootPath()+"/dfhcprojectmodule/update?jsguid="+$('#id').val();
	refreshUrl = location.href;
	</c:if>
	$("#url").val(url);
	$("#refreshUrl").val(refreshUrl);
}
/**
 * 提交主表
 */
 function commitMain(){
 	var url = getRootPath()+"/dfhcprojectmodule/commit?jsguid="+$('#id').val();
 	$("#url").val(url);
	$("#refreshUrl").val('');
 }
</script> 
</body>
</html>
